/**
 * 
 */
package com.gragra.sequentiaDataGenerator;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Arrays;
import com.gragra.sampling.sequentialStructure.CaseLevel;
import com.gragra.sampling.sequentialStructure.ExtensionLevels;
/**
 * This segmenter extends the functionality of another segmenter by adding CaseTypeLevel Information to
 * all the arrays that the other segmenter returns in the Collection given by its segment function, it
 * then replaces the word (the first entry in the array) by the version of the word returned by calling
 * toLowerCase on the word; it decides which CaseTypeLevel information should be used by calling the
 * getValueFor method of CaseTypeLevel
 * @author Christoph Teichmann
 * created Mar 27, 2013 4:01:10 PM
 * @version 0.1
 */
public class CaseLevelAssigningSegmenter implements Segmentation
{
	/**
	 * the segmenter that is wrapped to do the initial segmentation has to be given when a new instance is
	 * created
	 * @param seg
	 */
	public CaseLevelAssigningSegmenter(Segmentation seg)
	{this.seg = seg;}
	/**
	 * the wrapped segmentation tool
	 */
	private final Segmentation seg;
	/* (non-Javadoc)
	 * @see com.gragra.sequentiaDataGenerator.Segmentation#segment(java.lang.String)
	 */
	@Override
	public ObjectArrayList<String[]> segment(String s)
	{
		ObjectArrayList<String[]> co = seg.segment(s);
		for(int i=0;i<co.size();++i)
		{
			String[] base = co.get(i);
			int l = base.length;
			base = Arrays.copyOf(base, l+2);
			base[l] = ExtensionLevels.CaseTypeLevel.name();
			base[l+1] = CaseLevel.getValueFor(base[0]);
			base[0] = base[0].toLowerCase();
			co.set(i, base);
		}
		return co;
	}
}